package com.ams.io.network;

public abstract class NetworkHandler implements Runnable {
    protected static int TIMEOUT = 5000;
    protected boolean running = true;
    protected Thread thread = null;

    public boolean isRunning() {
        return running;
    }

    public void start(String name) {
        running = true;
        this.thread = new Thread(this, name);
        this.thread.start();
    }

    public void stop() {
        running = false;
        try {
            if (thread != null) {
                thread.interrupt();
                thread.join(TIMEOUT);
            }
        } catch (InterruptedException e) {
        }
    }
}
